package tingjingjiali

import (
	"influxdbDemoData/influxdb"
	"influxdbDemoData/mongodb"
	"influxdbDemoData/sysinit"
	"github.com/astaxie/beego"
)

var mgoConnect *mongodb.Connect
var influxdbConnect *influxdb.Connect

func init() {
	beego.LoadAppConfig("ini", "../../conf/app-mgo.conf")
	sysinit.InitDatabase([]string{"mysql"})
	sysinit.InitLogs()
	if false {
		//初始化 mongodb
		mgourl := beego.AppConfig.String("mgo::url")
		mgousername := beego.AppConfig.String("mgo::username")
		mgopassword := beego.AppConfig.String("mgo::password")
		mgodbname := beego.AppConfig.String("mgo::dbname")
		mgoauthmechanism := beego.AppConfig.String("mgo::authmechanism")
		//创建连接
		mgoConnect = mongodb.NewConnect(mgourl, mgousername, mgopassword, mgodbname, mgoauthmechanism)
	}
	//创建链接Influxdb
	iaddr := beego.AppConfig.String("influxdb::addr")
	ipassword := beego.AppConfig.String("influxdb::password")
	iusername := beego.AppConfig.String("influxdb::username")
	idbname := beego.AppConfig.String("influxdb::dbname")
	itimezone := beego.AppConfig.String("influxdb::timezone")

	influxdbConnect = influxdb.NewConnect(iaddr, iusername, ipassword, idbname, itimezone)
}
